<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<style type="text/css">
</style>
		<script type="text/javascript">
			$(function() {
				$("form").Validform({
					ajaxPost : true,
					tiptype : ValidUtils.siblingTip,
					callback : function(data) {
						helper.showMsg(data, {
							okHandler : function() {
								location = "../log/viewLogByTime?id=" + data.student.id;
							}
						});
					}
				});

				$('input[name=source]').closest("div.input-prepend").find("li a").click(function(e) {
					var v = $(this).text();
					$(':input[name=source]').val(v);
					return true;
				});

				$("#name").change(function() {
					$("#nameCheck").empty();
					var v = $(this).val();
					if (v.length > 1) {
						var url = "../student/doCheckStudentName";
						$.post(url, {
							name : v
						}, function(data) {
							if (data.success) {
								var html = [ '<div class="dropdown">', '<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">', '同名的学员<span class="caret"></span>', '</a>', '<ul class="dropdown-menu">' ];

								for ( var i = 0; i < data.students.length; i++) {
									var student = data.students[i];
									var li = [ '<li><a target="listStudent" href="../log/viewLogByTime?id=', student.id, '">', student.name, '(', student.mobile, ')</a>', '</li>', ];

									html = html.concat(li);
								}

								html.push('</ul>');
								html.push('</div>');

								var aEle = $(html.join(''));
								$("#nameCheck").append(aEle);
							}
						});
					}
				});

				$("#mobile").change(function() {
					$("#mobileCheck").empty();
					var v = $(this).val();
					if (v.length > 1) {
						var url = "../student/doCheckMobile";
						$.post(url, {
							mobile : v
						}, function(data) {
							if (data.success) {
								var html = [ '<div class="dropdown">', '<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">', '同号码用户<span class="caret"></span>', '</a>', '<ul class="dropdown-menu">' ];

								for ( var i = 0; i < data.students.length; i++) {
									var student = data.students[i];
									var li = [ '<li><a target="listStudent" href="../log/viewLogByTime?id=', student.id, '">', student.name, '(', student.mobile, ')</a>', '</li>', ];

									html = html.concat(li);
								}

								html.push('</ul>');
								html.push('</div>');

								var aEle = $(html.join(''));
								$("#mobileCheck").append(aEle);
							}
						});
					}
				});
			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<form class="form-horizontal" action="doFirstVisit">
			<div class="row-fluid">
				<div class="span6">
					<fieldset>
						<legend>人员登记</legend>
						<div class="control-group">
							<label class="control-label">内部编号</label>
							<div class="controls">
								<input type="text" name="no" value="${no}" readonly="readonly">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">姓名</label>
							<div class="controls">
								<input type="text" name="name" id="name" value="${param.name}" dataType="required"> <span id="nameCheck"></span> <span class="Validform_checktip"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">性别</label>
							<div class="controls">
								<label class="radio">
									男<input type="radio" name="sex" value="Male" />
								</label>
								<label class="radio">
									女<input type="radio" name="sex" value="Female" />
								</label>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">职业</label>
							<div class="controls">
								<input type="text" name="job"><span></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">年龄</label>
							<div class="controls">
								<select name="age">
									<option value="0">未设置</option>
									<s:iterator begin="1" end="100" var="age">
										<option value="${age}">${age}</option>
									</s:iterator>
								</select>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">教育程度</label>
							<div class="controls">
								<select name="education">
									<option value="">未设置</option>
									<option>学龄前</option>
									<option>小学</option>
									<optgroup label="中等教育">
										<option>初中</option>
										<option>高中</option>
										<option>中职</option>
										<option>职高</option>
										<option>技校</option>
									</optgroup>
									<optgroup label="高等教育">
										<option>专科</option>
										<option>本科</option>
										<option>硕士研究生</option>
										<option>博士研究生</option>
									</optgroup>
								</select>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">移动电话</label>
							<div class="controls">
								<input type="text" name="mobile" value="${param.number}" /><span id="mobileCheck"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">固定电话</label>
							<div class="controls">
								<input type="text" name="phone" />
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">电子邮箱</label>
							<div class="controls">
								<input type="text" name="email" />
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">邮政编码</label>
							<div class="controls">
								<input type="text" name="zip" />
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">详细地址</label>
							<div class="controls">
								<textarea name="address"></textarea>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">备注</label>
							<div class="controls">
								<textarea name="stu-title"></textarea>
							</div>
						</div>
					</fieldset>
				</div>
				<div class="span6">
					<fieldset>
						<legend>初次来访</legend>
						<div class="control-group">
							<label class="control-label">值班前台</label>
							<div class="controls">
								<select name="front" dataType="required">
									<option value="">==请选择==</option>
									<s:iterator value="fronts" var="front">
										<option value="${front.id}" <s:if test="profile.userId == #front.id">selected="selected"</s:if>>${front.name}</option>
									</s:iterator>
								</select><span class="Validform_checktip"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">来源渠道</label>
							<div class="controls">
								<div class="input-prepend">
									<div class="btn-group">
										<button class="btn dropdown-toggle" data-toggle="dropdown">
											<span class="caret"></span>
										</button>
										<ul class="dropdown-menu" id="times_select_menu">
											<li><a href="javascript:void(0)">市场做单</a></li>
											<li><a href="javascript:void(0)">市场活动</a></li>
											<li><a href="javascript:void(0)">销售预约</a></li>
											<li><a href="javascript:void(0)">团体报名</a></li>
											<li><a href="javascript:void(0)">平面广告</a></li>
											<li><a href="javascript:void(0)">内部推荐</a></li>
											<li><a href="javascript:void(0)">主动上门</a></li>
										</ul>
									</div>
									<input name="source" class="input-small" type="text" value="" />
								</div>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">来访备注</label>
							<div class="controls">
								<textarea name="visit-title"></textarea>
							</div>
						</div>
					</fieldset>

					<fieldset>
						<legend>安排咨询</legend>
						<div class="control-group">
							<label class="control-label">选择</label>
							<div class="controls">
								<select name="consultId" dataType="required">
									<option value="">==请选择==</option>
									<s:iterator value="users" var="user">
										<option value="${user.id}">${user.name}</option>
									</s:iterator>
								</select><span class="Validform_checktip"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">预报课程</label>
							<div class="controls">
								<select name="courseId">
									<option value="">未设置</option>
									<s:iterator value="#courses" var="course">
										<option value="${course.id}">${course.name}</option>
									</s:iterator>
								</select>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label">说明</label>
							<div class="controls">
								<input type="text" name="title">
							</div>
						</div>
					</fieldset>

					<div class="control-group">
						<div class="controls">
							<button class="btn btn-primary">
								<i class="icon-white icon-ok"></i>提交
							</button>
						</div>
					</div>
				</div>
			</div>
		</form>
	</tiles:putAttribute>
</tiles:insertDefinition>